package jdbc3_25;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class JDBCDemo07 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()){
            String sql = "SELECT id,username,password,nickname,age "+
                    "FROM user "+
                    "WHERE username=? AND password=? ";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"www");
            ps.setString(2,"212121");
            ResultSet rs = ps.executeQuery();
            System.out.println(rs.next()?"登录成功":"登录失败");

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
